﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace WallpaperEngine.Core
{
    public abstract class WallpaperCore
    {
        protected Wallpaper _wallpaper;

        private static IEnumerable<string> imgExtentions = new string[] { ".jpg", ".bmp", ".png" };

        static IEnumerable<string> vedioExtentions = new string[] { ".mp4", ".mov", "avi", "mkv", "3gp", "wmv", "mpg" };

        static IEnumerable<string> webExtentions = new string[] { ".html", ".htm" };

        static IEnumerable<string> processExtentions = new string[] { ".exe" };

        public WallpaperCore(Wallpaper wallpaper)
        {
            _wallpaper = wallpaper;
        }

        public static WallpaperCore GetWallpaperCore(Wallpaper wallpaper)
        {
            var extention = PathManager.FileExtention.ToLower();
            if (imgExtentions.Contains(extention))
            {
                return new WallpaperImg(wallpaper);
            }
            else if (vedioExtentions.Contains(extention))
            {
                return new WallpaperVedio(wallpaper);
            }
            else if (webExtentions.Contains(extention))
            {
                return new WallpaperWeb(wallpaper);
            }
            else if (processExtentions.Contains(extention))
            {
                return new WallpaperProcess(wallpaper);
            }
            else
            {
                throw new ArgumentException("无效的格式", $"文件后缀为{extention}");
            }
        }
    }
}
